package com.hp.modules.sys.entity;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.hp.common.annotation.DictEnum;
import com.hp.common.base.CodedEnum;
import com.hp.common.base.YesNoEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import tk.mybatis.mapper.annotation.LogicDelete;

import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * @author:mcfan
 * @description:
 * @date: create in 9:21 2021/4/8
 */
@Table(name = "sys_role")
@ApiModel(description = "角色")
public class SysRole implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = -1L;

    @Id
    @ApiModelProperty(value = "主键",position = 1)
    private Long id;
    @ApiModelProperty(value = "角色名称",position = 10)
    private String name;
    @ApiModelProperty(value = "角色标识(唯一)", position = 15)
    private String roleKey;
    @ApiModelProperty(value = "角色类型(10->管理员|ADMIN,20->流程审核员|WORKFLOW)", position = 20)
    private RoleTypeEnum roleType;
    @ApiModelProperty(value = "数据范围(10->所有数据权限|ALL,20->部门数据权限|DEPT,30->部门及以下数据权限|DEPT_CHILD,40->仅本人数据权限|MYSELF,50->自定义数据权限|CUSTOM)", position = 25)
    private DataScopeEnum dataScope;
    @ApiModelProperty(value = "是否启用(1->禁用|NO,2->启用|YES)", position = 30)
    private YesNoEnum isEnabled;
    @ApiModelProperty(value = "备注", position = 35)
    private String remark;
    @ApiModelProperty(value = "创建时间", position = 40)
    private Date createTime;
    @ApiModelProperty(value = "更新时间", position = 45)
    private Date updateTime;
    @ApiModelProperty(value = "是否删除(1->未删除|NO,2->已删除|YES)", position = 50)
    @LogicDelete(isDeletedValue=YesNoEnum.Y,notDeletedValue=YesNoEnum.N)
    private YesNoEnum isDeleted;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRoleKey() {
        return roleKey;
    }

    public void setRoleKey(String roleKey) {
        this.roleKey = roleKey;
    }

    public RoleTypeEnum getRoleType() {
        return roleType;
    }

    public void setRoleType(RoleTypeEnum roleType) {
        this.roleType = roleType;
    }

    public DataScopeEnum getDataScope() {
        return dataScope;
    }

    public void setDataScope(DataScopeEnum dataScope) {
        this.dataScope = dataScope;
    }

    public YesNoEnum getIsEnabled() {
        return isEnabled;
    }

    public void setIsEnabled(YesNoEnum isEnabled) {
        this.isEnabled = isEnabled;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public YesNoEnum getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(YesNoEnum isDeleted) {
        this.isDeleted = isDeleted;
    }

    @DictEnum(key="sys_role_role_type",name="角色类型")
    public enum RoleTypeEnum implements CodedEnum {
        /**
         * 管理员
         */
        ADMIN(10, "管理员"),
        /**
         * 流程审核员
         */
        WORKFLOW(20, "流程审核员");

        private int value;
        private String name;
        @JsonCreator
        public static RoleTypeEnum forValue(int value) {
            return CodedEnum.codeOf(RoleTypeEnum.class, value).get();

        }
        RoleTypeEnum(int value, String name) {
            this.value = value;
            this.name = name;
        }
        @JsonValue
        public int getValue() {
            return value;
        }
        public String getName() {
            return name;
        }

    }
    @DictEnum(key="sys_role_data_scope",name="数据范围")
    public enum DataScopeEnum implements CodedEnum {
        /**
         * 所有数据权限
         */
        ALL(10, "所有数据权限"),
        /**
         * 部门数据权限
         */
        DEPT(20, "部门数据权限"),
        /**
         * 部门及以下数据权限
         */
        DEPT_CHILD(30, "部门及以下数据权限"),
        /**
         * 仅本人数据权限
         */
        MYSELF(40, "仅本人数据权限"),
        /**
         * 自定义数据权限
         */
        CUSTOM(50, "自定义数据权限");
        private int value;
        private String name;
        @JsonCreator
        public static DataScopeEnum forValue(int value) {
            return CodedEnum.codeOf(DataScopeEnum.class, value).get();

        }
        DataScopeEnum(int value, String name) {
            this.value = value;
            this.name = name;
        }
        @JsonValue
        public int getValue() {
            return value;
        }
        public String getName() {
            return name;
        }

    }
}
